package app;


import java.util.*;

enum ImpurityMeasure {
	Gini, Entropy
};

public class DataSet {
	private AttributeSet attributeSet;
	private SymbolicAttribute problemClass;
	private Vector<Instance> instanceSet;

	public DataSet() {

	}

	public DataSet(AttributeSet attributeSet) {
		if (attributeSet == null)
			throw new IllegalArgumentException("Invalid argument");

		this.attributeSet = attributeSet;
		// TODO: test if the problem class is an SymbolicAttribute
		this.problemClass = (SymbolicAttribute) attributeSet.get(attributeSet.size() - 1);

		instanceSet = new Vector<Instance>();
	}

	public void add(Instance instance) {
		if (instance == null || instance.noAttributes() != attributeSet.size())
			throw new IllegalArgumentException("Invalid instance");

		instanceSet.add(instance);
	}

	public AttributeSet getAttributeSet() {
		return this.attributeSet;
	}
	
	public Vector<Instance> getInstanceSet() {
		return instanceSet;
	}
	
	public SymbolicAttribute getProblemClass() {
		return problemClass;
	}

	public boolean isEmpty() {
		return instanceSet.size() <= 0;
	}

	public String toString() {
		String str = "";

		str += attributeSet + "\n";
		str += "Problem class: " + problemClass + "\n";

		str += "Instances: \n";
		for (Instance instance : instanceSet) {
			str += instance;
		}

		return str;
	}
}
